<template>
  <a-spin :spinning="confirmLoading">
    <JFormContainer :disabled="disabled">
      <!-- 盲板-->
      <template #detail>
        <a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-row>
            <a-col :span="12">
            	<a-form-item label="作业证编号" v-bind="validateInfos.number">
            		<a-input v-model:value="formData.number" placeholder="请输入预约编号" disabled allow-clear ></a-input>
            	</a-form-item>
            </a-col>
            <a-col :span="12">
            	<a-form-item label="申请时间" v-bind="validateInfos.applyTime">
            		<a-date-picker placeholder="请选择申请时间"  v-model:value="formData.applyTime" showTime value-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"  allow-clear />
            	</a-form-item>
            </a-col>
            <a-col :span="12">
            	<a-form-item label="作业申请单位" v-bind="validateInfos.applyCompany">
                <j-select-dept v-model:value="formData.applyCompany" :multiple="true" checkStrictly  allow-clear disabled rowKey="orgCode"/>
            	</a-form-item>
            </a-col>
            <a-col :span="12">
            	<a-form-item label="申请人" v-bind="validateInfos.applicant">
                <j-select-user v-model:value="formData.applicant"  allow-clear disabled/>
            	</a-form-item>
            </a-col>
            <!-- <a-col :span="12">
            	<a-form-item label="作业地点" v-bind="validateInfos.locations">
            		<a-input v-model:value="formData.locations" placeholder="请输入作业地点"  allow-clear ></a-input>
            	</a-form-item>
            </a-col> -->
            <a-col :span="12">
            	<a-form-item label="归属装置" v-bind="validateInfos.device">
            		<j-dict-select-tag v-model:value="formData.device" dictCode="tb_base_risk_device,name,id" placeholder="请选择归属装置"  allow-clear  @change="changeDeviceId"/>
            	</a-form-item>
            </a-col>
            <a-col :span="12">
            	<a-form-item label="归属单元" v-bind="validateInfos.cell">
            		<j-dict-select-tag v-model:value="formData.cell" :dictCode="argument.unitDictCode" placeholder="请选择归属单元"  allow-clear :disabled="argument.riskUnitFlag"/>
            	</a-form-item>
            </a-col>
            <!-- <a-col :span="12">
            	<a-form-item label="作业部位" v-bind="validateInfos.position">
            		<a-input v-model:value="formData.position" placeholder="请输入作业部位"  allow-clear ></a-input>
            	</a-form-item>
            </a-col> -->
            <a-col :span="24">
            	<a-form-item label="作业内容" v-bind="validateInfos.content">
            		<a-textarea v-model:value="formData.content" :rows="4" placeholder="请输入作业内容" />
            	</a-form-item>
            </a-col>
            
            <a-divider>盲板详细信息</a-divider>
            <a-col :span="12">
              <a-form-item label="盲板作业类型" v-bind="validateInfos.blindPlateJobType">
                <j-dict-select-tag type='radio' v-model:value="formData.blindPlateJobType" dictCode="blindplatejobType" placeholder="请选择盲板作业类型"  allow-clear />
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="设备管道名称" v-bind="validateInfos.equipmentPipeName">
                <a-input v-model:value="formData.equipmentPipeName" placeholder="请输入设备管道名称"  allow-clear ></a-input>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="设备原有介质" v-bind="validateInfos.equipmentNativeMedium">
                <a-input v-model:value="formData.equipmentNativeMedium" placeholder="请输入设备原有介质"  allow-clear ></a-input>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="设备温度" v-bind="validateInfos.equipmentTemperature">
                <a-input v-model:value="formData.equipmentTemperature" placeholder="请输入设备温度"  allow-clear ></a-input>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="设备压力" v-bind="validateInfos.equipmentPressure">
                <a-input v-model:value="formData.equipmentPressure" placeholder="请输入设备压力"  allow-clear ></a-input>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="盲板材质" v-bind="validateInfos.blindSheet">
                <a-input v-model:value="formData.blindSheet" placeholder="请输入盲板材质"  allow-clear ></a-input>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="盲板规格" v-bind="validateInfos.blindPlateSpecification">
                <a-input v-model:value="formData.blindPlateSpecification" placeholder="请输入盲板规格"  allow-clear ></a-input>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="盲板编号" v-bind="validateInfos.blindPlateNumber">
                <a-input v-model:value="formData.blindPlateNumber" placeholder="请输入盲板编号"  allow-clear ></a-input>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="盲板位置图" v-bind="validateInfos.blindPlateImg">
                <j-image-upload :fileMax="0" v-model:value="formData.blindPlateImg" ></j-image-upload>
              </a-form-item>
            </a-col>
            
            <a-divider>监护信息</a-divider>
            <a-col :span="12">
            	<a-form-item label="施工单位" v-bind="validateInfos.operationCompany">
            		<a-input v-model:value="formData.operationCompany" placeholder="请输入施工单位"  allow-clear disabled style="width: calc(70% - 80px)"></a-input>
                <a-button ghost color="success" @click="activeKeyCompany('1')"> 企内单位 </a-button>
                <a-button ghost color="warning" @click="activeKeyCompany('2')"> 承包商 </a-button>
            	</a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="作业负责人" v-bind="validateInfos.operationManager">
                <a-input v-model:value="formData.operationManager" placeholder="请输入作业负责人"  allow-clear style="width: calc(70% - 60px)"></a-input>
                <a-button ghost color="success" @click="activeKeyOperator('9')"> 企内单位 </a-button>
                <a-button ghost color="warning" @click="activeKeyOperator('10')"> 承包商 </a-button>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="作业人" v-bind="validateInfos.operatorAndCode">
                <a-input v-model:value="formData.operatorAndCode" placeholder="请输入作业人"  allow-clear style="width: calc(70% - 60px)"></a-input>
                <a-button ghost color="success" @click="activeKeyOperator('11')"> 企内单位 </a-button>
                <a-button ghost color="warning" @click="activeKeyOperator('12')"> 承包商 </a-button>
              </a-form-item>
            </a-col>
            <a-col :span="12">
            	<a-form-item label="企内监护人" v-bind="validateInfos.companyGuardian">
                <a-input v-model:value="formData.companyGuardian" placeholder="请输入企内监护人"  allow-clear disabled style="width: calc(90% - 60px)"></a-input>
                <a-button ghost color="success" @click="selectCompanyGuardian"> 查询 </a-button>
            	</a-form-item>
            </a-col>
            <a-col :span="12">
            	<a-form-item label="施工单位监护人" v-bind="validateInfos.constructionGuardian">
            		<a-input v-model:value="formData.constructionGuardian" placeholder="请输入施工单位监护人"  allow-clear disabled  style="width: calc(70% - 60px)"></a-input>
                <a-button ghost color="success" @click="activeKeyOperator('7')"> 企内单位 </a-button>
                <a-button ghost color="warning" @click="activeKeyOperator('8')"> 承包商 </a-button>
              </a-form-item>
            </a-col>
            <a-col :span="12">
            	<a-form-item label="作业原因" v-bind="validateInfos.jobReason">
                <j-select-multiple type="list_multi" v-model:value="formData.jobReason" dictCode="jobReason" placeholder="请选择作业原因"  :triggerChange="false"/>
            	</a-form-item>
            </a-col>
            <a-col :span="12">
            	<a-form-item label="作业计划开始时间" v-bind="validateInfos.planStartDate">
            		<a-date-picker placeholder="请选择作业计划开始时间"  v-model:value="formData.planStartDate" showTime value-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"  allow-clear />
            	</a-form-item>
            </a-col>
            <a-col :span="12">
            	<a-form-item label="作业结束时间" v-bind="validateInfos.planEndDate">
            		<a-date-picker placeholder="请选择作业结束时间"  v-model:value="formData.planEndDate" showTime value-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"  allow-clear />
            	</a-form-item>
            </a-col>
						<a-col :span="24">
							<a-form-item label="关联的其他特殊作业及安全作业票编号" v-bind="validateInfos.relevanceNumber">
								<a-input v-model:value="formData.relevanceNumber" placeholder="请选择关联的其他特殊作业及安全作业票编号"  allow-clear disabled style="width: calc(90% - 60px)"></a-input>
								<a-button ghost color="success" @click="selectRelevanceNumber"> 查询 </a-button>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="风险辨识结果" v-bind="validateInfos.riskIdentificationResult">
								<j-select-multiple type="list_multi" v-model:value="formData.riskIdentificationResult" dictCode="jobRiskIdentification" placeholder="请选择危害辨识"  :triggerChange="false"/>
							</a-form-item>
						</a-col>
						<a-col :span="12">
							<a-form-item label="定位" v-bind="validateInfos.orientation">
								<a-input v-model:value="formData.orientation" placeholder="请输入定位"  allow-clear ></a-input>
							</a-form-item>
						</a-col>
          </a-row>
        </a-form>
      </template>
    </JFormContainer>
    
    <!-- 添加部门弹窗 -->
    <SelectDeptModel ref="deptModal" @success="selectDeptSuccess"/>
    <!-- 承包商弹窗 -->
    <SelectContractorModal ref="contractorModal" @success="selectContractorSuccess"/>
    <!--承包商人员表格-施工单位负责人-->
    <ContractorPersonnelTable @register="contractorPersonnelDrawer" @success="selectContractorPersonnelSuccess"  :disableUserEdit="true"/>
    <!--承包商人员表格-证书列表-->
    <ContractorPersonnelCertificateTable @register="contractorPersonnelCertificateDrawer" @success="selectContractorPersonnelCertificateSuccess"  :disableUserEdit="true"/>
    <!--企业内用户表格-施工单位负责人-->
    <UserTable @register="userDrawer" @success="selectUserSuccess"  :disableUserEdit="true"/>
    
    <!--企业内用户表格-施工单位监护人-->
    <GuardianHeadquartersTable @register="guardianHeadquartersTableDrawer" @success="selectGuardianHeadquartersTableSuccess"  :disableUserEdit="true"/>
    <!--企业内用户表格-施工单位监护人-->
    <ContractorPersonnelGuardianTable @register="contractorPersonnelGuardianDrawer" @success="selectContractorPersonnelGuardianSuccess"  :disableUserEdit="true"/>
    <!-- 相关的作业票弹窗 -->
    <SelectRelevanceJobTicketModal ref="relevanceJobTicketModal" @success="selectRelevanceJobTicketSuccess"/>
  </a-spin>
</template>

<script lang="ts" setup>
  import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted } from 'vue';
  import { useMessage } from '/@/hooks/web/useMessage';
  import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
  import JSelectMultiple from '/@/components/Form/src/jeecg/components/JSelectMultiple.vue';
  import JSelectDept from '/@/components/Form/src/jeecg/components/JSelectDept.vue';
  import JSelectUser from '/@/components/Form/src/jeecg/components/JSelectUser.vue';
  import { getValueType } from '/@/utils';
  import { queryJobCode,saveGenerateTickets } from '../TbJobTicket.api';
  import { Form } from 'ant-design-vue';
  import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
  import { useUserStore } from '/@/store/modules/user';
  import SelectDeptModel from './SelectDeptModel.vue';
  import SelectContractorModal from '@/views/contractor/components/SelectContractorModal.vue';
  import SelectContractorPersonnelModal from '@/views/contractor/components/SelectContractorPersonnelModal.vue';
  import ContractorPersonnelCertificateTable from '@/views/contractor/components/ContractorPersonnelCertificateTable.vue';
  import ContractorPersonnelTable from '@/views/contractor/components/ContractorPersonnelTable.vue';
  import GuardianHeadquartersTable from '@/views/job/guardian/components/GuardianHeadquartersTable.vue';
  import ContractorPersonnelGuardianTable from '@/views/contractor/components/ContractorPersonnelGuardianTable.vue';
  import UserTable from '@/views/system/user/UserTable.vue';
  import { useDrawer } from '/src/components/Drawer';
  import JImageUpload from '/@/components/Form/src/jeecg/components/JImageUpload.vue';
  
  const props = defineProps({
    formDisabled: { type: Boolean, default: false },
    formData: { type: Object, default: () => ({})},
    formBpm: { type: Boolean, default: true }
  });
  const formRef = ref();
  const useForm = Form.useForm;
  const emit = defineEmits(['register', 'ok']);
  const formData = reactive<Record<string, any>>({
    id: '',
    content: '',   
    number: '',   
    jobReason: '',   
    device: '',   
    cell: '',   
    jobType: '',   
    planStartDate: '',   
    planEndDate: '',   
    applyCompany: '',   
    applicant: '',   
    position: '',   
    operationCompanyId: '',
    operationCompany: '',   
    operationChargePerson: '',   
    constructionMan: '',   
    locations: '',   
    companyGuardian: '',   
    constructionGuardian: '',   
    relevanceNumber: '',   
    riskIdentificationResult: '',   
    orientation: '',   
    videoId: '',   
    status: '2',   
    deleted: '0',   
    eventsId: '',
  });
  const { createMessage } = useMessage();
  const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 4 } });
  const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
  const confirmLoading = ref<boolean>(false);
  //表单验证
  const validatorRules = reactive({
    content: [{ required: true, message: '请输入作业内容!'},],
    number: [{ required: true, message: '请输入预约编号!'},],
    jobReason: [{ required: true, message: '请输入作业原因!'},],
    device: [{ required: true, message: '请输入归属装置!'},],
    cell: [{ required: true, message: '请输入归属单元!'},],
    jobType: [{ required: true, message: '请输入作业类型!'},],
    planStartDate: [{ required: true, message: '请输入作业开始时间!'},],
    planEndDate: [{ required: true, message: '请输入作业结束时间!'},],
    operatorAndCode: [{ required: true, message: '请输入作业人及证书编号!'},],
    applicant: [{ required: true, message: '请输入作业申请人!'},],
    operationChargePerson: [{ required: false, message: '请输入作业所属单位负责人!'},],
    //locations: [{ required: true, message: '请输入作业地点!'},],
    riskIdentificationResult: [{ required: true, message: '请输入风险辨识结果!'},],
    blindPlateJobType: [{ required: true, message: '请输入盲板作业类型!'},],
    equipmentPipeName: [{ required: true, message: '请输入设备管道名称!'},],
    blindPlateNumber: [{ required: true, message: '请输入盲板编号!'},],
    companyGuardian: [{ required: true, message: '请输入公司监护人!'},],
    constructionGuardian: [{ required: true, message: '请输入施工单位监护人!'},],
  });
  const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
  
  const argument = reactive({
    unitDictCode: "tb_base_risk_unit,risk_unit_name,id",
    riskUnitFlag: true,
    operatorType: ""
  })
  const userStore = useUserStore();
  const deptModal = ref();
  const contractorModal = ref();
  const contractorPersonnelModal = ref()
  //注册drawer承包商人员
  const [contractorPersonnelDrawer, { openDrawer: openContractorPersonnelDrawer }] = useDrawer();
  //注册drawer承包商人员证书
  const [contractorPersonnelCertificateDrawer,{ openDrawer: openContractorPersonnelCertificateDrawer }] = useDrawer();
  //注册drawer企业内人员
  const [userDrawer, { openDrawer: openUserDrawer }] = useDrawer();
  
  //注册drawer企业内监护人
  const [guardianHeadquartersTableDrawer, { openDrawer: openGuardianHeadquartersDrawer }] = useDrawer();
  //注册drawer承包商监护人
  const [contractorPersonnelGuardianDrawer, { openDrawer: openContractorPersonnelGuardianDrawer }] = useDrawer();

  // 表单禁用
  const disabled = computed(()=>{
    if(props.formBpm === true){
      if(props.formData.disabled === false){
        return false;
      }else{
        return true;
      }
    }
    return props.formDisabled;
  });

  function changeDeviceId(id) {
    if(id){
      formData.riskUnitId = null;
      argument.riskUnitFlag = false;
    }else{
      argument.riskUnitFlag = true;
    }
    argument.unitDictCode = "tb_base_risk_unit,risk_unit_name,id,device_id="+id
  }
  
  /**
   * 人员选择
   */
  function activeKeyOperator(val) {
    argument.operatorType = val;
    /* 7表特殊用的是企业内的监护人组件*/
    if(val == '1' || val == '3' || val == '5' || val == '9' || val == '11'){
      openUserDrawer(true, null);
    }else if(val == "2" || val == '4' || val == '6' || val == '8' || val == '10'){
      openContractorPersonnelDrawer(true, null);
    }else if(val == "7"){
      openGuardianHeadquartersDrawer(true, null);
    }else if(val == "12"){
      openContractorPersonnelCertificateDrawer(true,null);
    }
  }
  
  function selectContractorPersonnelSuccess(selectedRows){
    if(selectedRows.length >0){
      const selectedContractorPersonnelNames = []
      selectedRows.forEach(item =>{
        selectedContractorPersonnelNames.push(item.name)
      })
      
      console.log("====selectedContractorPersonnelNames==========="+selectedContractorPersonnelNames)
      if(argument.operatorType =="1" || argument.operatorType == "2"){
        formData.liftingOperator= selectedContractorPersonnelNames.toString();
      }else if(argument.operatorType == "3" || argument.operatorType == "4"){
        formData.liftingSisot = selectedContractorPersonnelNames.toString();
      }else if(argument.operatorType == "5" || argument.operatorType == "6"){
        formData.liftingCommandingOfficer = selectedContractorPersonnelNames.toString();
      }else if(argument.operatorType == "7" || argument.operatorType == "8"){
        formData.constructionGuardian = selectedContractorPersonnelNames.toString();
      }else if(argument.operatorType == "9" || argument.operatorType == "10"){
        formData.operationManager = selectedContractorPersonnelNames.toString();
      }else if(argument.operatorType == "11" ){
        formData.operatorAndCode = selectedContractorPersonnelNames.toString();
      }
    }
  }
  
  function selectContractorPersonnelCertificateSuccess(selectedRows){
    if(selectedRows.length >0){
      const selectedContractorPersonnelCertificate = []
      selectedRows.forEach(item =>{
        selectedContractorPersonnelCertificate.push(item.name+item.number)
      })
      
      console.log("====selectContractorPersonnelCertificateSuccess==========="+selectedContractorPersonnelCertificate)
      formData.operatorAndCode = selectedContractorPersonnelCertificate.toString();
    }
  }
  
  function selectUserSuccess(selectedRows){
    if(selectedRows.length >0){
      const selectedOperatorAndCodes = []
      selectedRows.forEach(item =>{
        selectedOperatorAndCodes.push(item.realname)
      })
      
      console.log("====selectedOperatorAndCodes==========="+selectedOperatorAndCodes)
      if(argument.operatorType =="1" || argument.operatorType == "2"){
        formData.liftingOperator= selectedOperatorAndCodes.toString();
      }else if(argument.operatorType == "3" || argument.operatorType == "4"){
        formData.liftingSisot = selectedOperatorAndCodes.toString();
      }else if(argument.operatorType == "5" || argument.operatorType == "6"){
        formData.liftingCommandingOfficer = selectedOperatorAndCodes.toString();
      }else if(argument.operatorType == "7" || argument.operatorType == "8"){
        formData.constructionGuardian = selectedOperatorAndCodes.toString();
      }else if(argument.operatorType == "9" || argument.operatorType == "10"){
        formData.operationManager = selectedOperatorAndCodes.toString();
      }else if(argument.operatorType == "11" ){
        formData.operatorAndCode = selectedOperatorAndCodes.toString();
      }
    }
  }
  
  /**
   * 企业内还是承包商
   */
  function activeKeyCompany(val) {
    argument.operationCompanyType = val;
    if(val == '1'){
      deptModal.value.openIntraEnterpriseModel();
    }else if(val == "2"){
      contractorModal.value.openContractorModel();
    }
  }
  
  /* 获取部门弹窗回调函数参数*/
  function selectDeptSuccess(data){
    formData.operationCompanyId= data.deptId;
    formData.operationCompany= data.departName;
    console.log("-----data-----------"+JSON.stringify(formData))
  }
  
  /**
   * 选中的承包商信息
   */
  function selectContractorSuccess(selectedRows) {
    console.log("====selectedRows==========="+JSON.stringify(selectedRows))
    if(selectedRows.length >0){
      const selectedContractorIds = []
      const selectedContractorNames = []
      selectedRows.forEach(item =>{
        selectedContractorIds.push(item.id)
        selectedContractorNames.push(item.name)
      })
      formData.operationCompanyId= selectedContractorIds.toString();
      formData.operationCompany= selectedContractorNames.toString();
      console.log("====selectedContractorNames==========="+selectedContractorNames)
    }
  }
  
  /* 施工单位负责人查询*/
  function selectConstructionMan(){
    openUserDrawer(true, formData.operationCompanyId);
  }
  
  function selectCompanyGuardian(){
    openGuardianHeadquartersDrawer(true, null);
  }
  
  function selectGuardianHeadquartersTableSuccess(selectedRows){
    if(selectedRows.length >0){
      const selectedNames = []
      selectedRows.forEach(item =>{
        selectedNames.push(item.userName_dictText +item.orgcode + ",")
      })
      if(argument.operatorType == "7"){
        formData.constructionGuardian = selectedNames.toString().replace(/,$/, "");
      }else{
        formData.companyGuardian= selectedNames.toString().replace(/,$/, "");
      }
    }
  }
  
  function selectConstructionGuardian(){
    openContractorPersonnelGuardianDrawer(true, formData.operationCompanyId);
  }
  
  function selectContractorPersonnelGuardianSuccess(selectedRows){
    if(selectedRows.length >0){
      const selectedOperatorAndCodes = []
      selectedRows.forEach(item =>{
        selectedOperatorAndCodes.push(item.name + ",")
      })
      formData.constructionGuardian= selectedOperatorAndCodes.toString().replace(/,$/, "");;
      console.log("====selectedOperatorAndCodes==========="+selectedOperatorAndCodes)
    }
  }
  
  /* 获取关联的作业编号，等信息*/
  function selectRelevanceNumber(){
    relevanceJobTicketModal.value.openModel();
  }
  
  function selectRelevanceJobTicketSuccess(selectedRows){
    console.log("=====selectedRows======="+JSON.stringify(selectedRows))
    if(selectedRows.length >0){
      let relevanceNumberList = "";
      selectedRows.forEach(item =>{
        relevanceNumberList = relevanceNumberList + item.jobType_dictText + "-" + item.number + ","
      })
      formData.relevanceNumber = relevanceNumberList.replace(/,$/, '');
    }
  }
  
  /**
   * 新增
   */
  function add() {
    /* 获取编号之后再进行页面渲染*/
    queryJobCode({}).then((result) => {
      let addData = {
        applyCompany: userStore.getUserInfo.orgCode,
        applicant: userStore.getUserInfo.username,
        number: result,
      };
      edit(addData);
    });
  }

  /**
   * 编辑
   */
  function edit(record) {
    nextTick(() => {
      resetFields();
      const tmpData = {};
      Object.keys(formData).forEach((key) => {
        if(record.hasOwnProperty(key)){
          tmpData[key] = record[key]
        }
      })
      //赋值
      Object.assign(formData, tmpData);
    });
  }

  /**
   * 提交数据
   */
  async function submitForm() {
    // 触发表单验证
    await validate();
    confirmLoading.value = true;
    const isUpdate = ref<boolean>(false);
    //时间格式化
    let model = formData;
    if (model.id) {
      isUpdate.value = true;
    }
    //循环数据
    for (let data in model) {
      //如果该数据是数组并且是字符串类型
      if (model[data] instanceof Array) {
        let valueType = getValueType(formRef.value.getProps, data);
        //如果是字符串类型的需要变成以逗号分割的字符串
        if (valueType === 'string') {
          model[data] = model[data].join(',');
        }
      }
    }
    await saveGenerateTickets(model).then((res) => {
        if (res.success) {
          createMessage.success(res.message);
          emit('ok');
        } else {
          createMessage.warning(res.message);
        }
      })
      .finally(() => {
        confirmLoading.value = false;
      });
  }


  defineExpose({
    add,
    edit,
    submitForm,
  });
</script>

<style lang="less" scoped>
  .antd-modal-form {
    padding: 14px;
  }
</style>
